package cate.game.activity.merge.msg;

import cate.common.table.d.GDFunc;
import cate.game.GameBody;
import cate.game.activity.dailylogin.DailyLoginSingle;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBMergeAct;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

@ClientMsg(title = "合服活动-登录-领奖 请求")
public class MergeLoginActivityGetReq implements MsgInput {
    @NoteField(value = "奖励项配置ID")
    public int itemTid;

    @Override
    public MsgConfig conf() {
        return MsgIdBMergeAct.MERGE_ACT_LOGIN_GET_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        DailyLoginSingle loginSingle = cc.getRole().getActivity().getEnableActivitySingle(GDFunc.MergeAct.MERGE_ACT_LOGIN);
        if (loginSingle == null) {
            game.notice.message(cc.getRole(), "合服登录活动未开启");
        } else {
            EcResult<DailyLoginSingle> r = loginSingle.receiveReward(itemTid);
            if (r.ok()) {
                r.data.noticeUpdate();
            }
            game.notice.message(cc.getRole(), r, true);
        }
    }
}
